package model.dao;

import java.util.List;

import javax.ejb.Local;
import javax.ejb.Stateless;
import javax.persistence.NoResultException;
import javax.persistence.Query;

import model.entity.Photo;
import model.entity.Rating;

@Stateless
@Local(RatingDaoLocal.class)
public class RatingDaoBean extends GenericDaoBean<Rating, Integer> implements
		RatingDaoLocal {

	@Override
	public List<Rating> isUserRate(int userId, int photoId) {
		try{
			Query q = em.createNamedQuery("isUserRate");
			q.setParameter("userid", userId);
			q.setParameter("photoid", photoId);
			return (List<Rating>) q.getResultList();
		}catch(NoResultException e){
			return null;
		}
	}

}
